const {run} = require("../model/run");

let reqData = async (ctx) =>{
    //console.log(ctx.request.body.item)
    //console.log('---------------------')
    var json ;
    if(typeof ctx.request.body.item == 'object'){
        json = ctx.request.body.item
    }else{
        json = JSON.parse(ctx.request.body.item)
    }
    //console.log(json.event[0].script.exec)
    let obj = {
        "item": [json]
    }
    //ctx.body = JSON.parse(ctx.request.body.item);
    let result = await run(obj);
    if(result){
        //console.log(result)
        ctx.body = result;
    }
}

module.exports = {
    reqData
}